byte arr[]=new byte[100]; n=in.read(arr);
byte arr[]=new byte[100]; n=in.read(arr,25,50);Note:the above methods will returns -1 at end of stream.
File fa=new File("c:/temp/demo.txt"); FileInputStream fin=new FileInputStream(fa);
import java.io.*; class demo { public static void main(String[ ] args) { try{ FileInputStream fin=new FileInputStream("c:\\temp\\info.txt"); int ch; while((ch=fin.read())!=-1) System.out.print((char)ch); fin.close(); } catch(Exception err) { System.out.println("ERROR:"+err); } } }
Welcome to CCIT Amravati
FileOutputStream fout=new FileOutputStream(“c:/temp/demo.txt”); Or File fa=new File(“c:/temp/demo.txt”); FileOutputStream fout=new FileOutputStream(fa);
import java.io.*; class demo { public static void main(String[ ] args) throws Exception { FileWriter fw=new FileWriter("c:\\temp\\myinfo.txt"); fw.write("P.Choudhari"); fw.write("\nCCIT\nRajapeth\nAmravati"); fw.close(); } }